<?php
namespace App\Http\Controllers;

use App\Models\Traffic;
use App\Models\Trafficline;
use Illuminate\Support\Facades\Schema;

class TrafficController extends WxBaseController{
    protected $except=['index','show','getLines'];
    public function index(){
        $traffics = Traffic::get();
        editImageUrl($traffics);
        return $this->apiReturn(true,'success',$traffics);
    }
    public function show($id){
        $traffic = Traffic::where('id',$id);
        //更新浏览量
        if(Schema::hasColumn('traffics', 'watch')){
            $traffic->increment('watch');
        };
        $arr=$traffic->get();
        editImageUrl($arr);
        return $this->apiReturn(true,'success',$arr);
    }
    public function getLines($id){
        $lines = Trafficline::where('traffic_id',$id)->get();
        editImageUrl($lines);
        return $this->apiReturn(true,'success',$lines);
    }
}